import {createSlice} from '@reduxjs/toolkit'


const ticket=createSlice({
    name:"ticket",
    initialState:{
        from:"北京",
        to:'上海'
    },
    reducers:{
        uoLoadSplace(state){
            const temp=state.from
            state.from=state.to
            state.to=temp
        },
        upLoadDate(state,action){
            // payload载体（数据）
            state.date=action.payload
        },
        upLoadCity(state,action){
            if(action.payload.type==='to'){
                state.to=action.payload.city
            }else{
                state.from=action.payload.city
            }
            
        }
    }
})
export default ticket.reducer
export const {uoLoadSplace,upLoadDate,upLoadCity}=ticket.actions